﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LP580.CG;

public partial class User_UC2Profile : System.Web.UI.Page
{
    private clsUserAccount ua = clsUserAccount.getCookieUser(true);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["act"] == "t")
            {
                clsUserCompanyInfo cls = new clsUserCompanyInfo(ua.UserID);
                cls.ContactPerson = Utils.RF_str(tbxContactPerson.Name);
                cls.Tel = Utils.RF_str(tbxTel.Name);
                cls.DeptName = Utils.RF_str(tbxDeptName.Name);
                cls.UserPosition = Utils.RF_str(tbxUserPosition.Name);
                cls.Fax = Utils.RF_str(tbxFax.Name);
                cls.Mobile = Utils.RF_str(tbxMobile.Name);
                cls.QQ = Utils.RF_str(tbxQQ.Name);
                cls.Email = Utils.RF_str(tbxEmail.Name);
                cls.Website = Utils.RF_str(tbxWebsite.Name);
                cls.CompanyAddress = Utils.RF_str(tbxCompanyAddress.Name);
                if (cls.UserID == 0)
                {
                    cls.UserID = ua.UserID;
                    clsUserCompanyInfo.Insert(cls);
                }
                else
                {
                    clsUserCompanyInfo.Update(cls);
                }
                Utils.WrAlertGo("提交成功！", "UC2Profile.aspx");
            }
            else if (Request.QueryString["act"] == "l")
            {
                clsUserCompanyInfo cls = new clsUserCompanyInfo(ua.UserID);
                cls.CompanyName = Utils.RF_str(tbxCompanyName.Name);
                cls.CompanyType = Utils.RF_str("tbxCompanyType");
                cls.RegisteredCapital = Utils.RF_str(tbxRegisteredCapital.Name);
                cls.CompanyProvince = Utils.RF_int("province");
                cls.CompanyCity = Utils.RF_int("city");
                cls.BuildYear = Utils.RF_str(tbxBuildYear.Name);
                cls.SalesType = Utils.RF_str("SalesType");
                cls.ClassCode = clsCompanyClass.NameToCode(cls.SalesType.Replace("礼品", ""));
                cls.SalesItem = Utils.RF_str(tbxSalesItem.Name);
                cls.CompanyAbout = Utils.RF_str("companyabout");
                if (cls.UserID == 0)
                {
                    cls.UserID = ua.UserID;
                    clsUserCompanyInfo.Insert(cls);
                }
                else
                {
                    clsUserCompanyInfo.Update(cls);
                }
                Utils.WrAlertGo("提交成功！", "UC2Profile.aspx");
            }
            else
            {
                clsUserCompanyInfo cls = new clsUserCompanyInfo(ua.UserID);
                tbxCompanyName.Value = cls.CompanyName;
                tbxSalesItem.Value = cls.SalesItem;
                tbxRegisteredCapital.Value = cls.RegisteredCapital;
                tbxBuildYear.Value = cls.BuildYear;
                tbxContactPerson.Value = cls.ContactPerson;
                tbxTel.Value = cls.Tel;
                tbxDeptName.Value = cls.DeptName;
                tbxUserPosition.Value = cls.UserPosition;
                tbxFax.Value = cls.Fax;
                tbxMobile.Value = cls.Mobile;
                tbxEmail.Value = cls.Email;
                tbxWebsite.Value = cls.Website;
                tbxQQ.Value = cls.QQ;
                tbxCompanyAddress.Value = cls.CompanyAddress;
                tbxCompanyAbout.Value = cls.CompanyAbout;
                tbxCompanyAbout.ToolbarSet = "Basic";
                Literal1.Text = string.Format("<em id='dv' pr='{0}' ct='{1}' st='{2}' cty='{3}'></em>", cls.CompanyProvince, cls.CompanyCity, cls.SalesType, cls.CompanyType); 
            }
        }
    }
}